﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using System.Security.Principal;

namespace MvcChat.Controllers
{
    public class LoginController : Controller
    {
        //
        // GET: /Login/

        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Index(string uiUsername, string uiPassword)
        {
           
            if (FormsAuthentication.Authenticate(uiUsername, uiPassword))
            {
                FormsAuthentication.SetAuthCookie(uiUsername, true);
            }
            ViewData["foo"] = "skrid!";

            IPrincipal user = HttpContext.User;
            if (user.Identity.IsAuthenticated)
            {
                ViewData["foo"] = "velkommen...";
            }
            
            return View();
        }
    }
}
